/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "<key_word>_service.h"
#include <unistd.h>
#include "file_ex.h"
#include "system_ability_definition.h"
#include "hilog_wrapper.h"
#include "<key_word>_errors.h"
#include "<key_word>_common.h"

namespace <namespace> {
namespace <Subsys_name> {
namespace {
const bool REGISTER_RESULT =
    SystemAbility::MakeAndRegisterAbility(DelayedSingleton<<Key_word>Service>::GetInstance().get());
}

<Key_word>Service::<Key_word>Service()
    : SystemAbility(<SERVICE_ID>, true),
    ready_(false)
{
}

<Key_word>Service::~<Key_word>Service() {}

void <Key_word>Service::OnDump()
{
    
}

void <Key_word>Service::OnStart()
{
    <KEY_WORD>_HILOGD(<KEY_WORD>_SRV, "Enter");
    if (ready_) {
        <KEY_WORD>_HILOGD(<KEY_WORD>_SRV, "Service is ready, nothing to do");
        return;
    }
    if (!(Init())) {
        <KEY_WORD>_HILOGE(<KEY_WORD>_SRV, "Call init failed");
        return;
    }

    if (!Publish(this)) {
        <KEY_WORD>_HILOGE(<KEY_WORD>_SRV, "Register to system ability manager failed");
        return;
    }
    ready_ = true;
}

bool <Key_word>Service::Init()
{
    <KEY_WORD>_HILOGD(<KEY_WORD>_SRV, "Enter");

    <KEY_WORD>_HILOGI(<KEY_WORD>_SRV, "Success");
    return true;
}

void <Key_word>Service::OnStop()
{
    <KEY_WORD>_HILOGW(<KEY_WORD>_SRV, "Enter");

    <KEY_WORD>_HILOGW(<KEY_WORD>_SRV, "Success");
}

int32_t <Key_word>Service::Dump(int32_t fd, const std::vector<std::u16string> &args)
{
    return ERR_OK;
}

<define>
} // namespace <Subsys_name>
} // namespace <namespace>
